package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.commons.util.ImageUtils;
import com.copm.demonstrationsystem.service.introductionfeatures.CompanyIntroductionService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 19:40 2018/4/16
 */

@RestController
@RequestMapping("/introduction")
@CrossOrigin
public class CompanyIntroductionController {

    ResponseStatus responseStatus;

    @Autowired
    CompanyIntroductionService companyIntroductionService;

    /**
     * 获取“企业简介”页面页面
     *
     * @param
     * @return
     */
    @ApiOperation("企业简介 页面信息的获取接口")
    @GetMapping()
    public ResponseStatus getCompanyIntroductionPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.getCompanyIntroduction());
    }

    /**
     * 添加“企业简介”页面图片
     */
    @ApiOperation("页面图片添加")
    @ApiImplicitParam(name = "file",value = "待添加图片信息"
            ,dataType = "file",paramType = "form",required = true)
    @PostMapping("/image")
    public ResponseStatus addImage(@RequestPart("file") MultipartFile file) throws Exception {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.addCompanyIntroductionImage(file));
    }

    /**
     * 通过图片id删除“企业简介”页面图片
     * @param id 图片id
     * @return
     */
    @ApiOperation("页面图片删除")
    @ApiImplicitParam(name = "id",value = "待删除图片id"
            ,dataType = "Long",paramType = "path",required = true)
    @DeleteMapping("/image/{id}")
    public ResponseStatus deleteImage(@PathVariable("id") Long id) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.deleteCompanyIntroductionImage(id));
    }


    /**
     * 修改“企业简介”页面视频链接地址内容
     *
     * @param url
     * @return
     */
    @ApiOperation("视频链接地址内容的修改")
    @ApiImplicitParam(name = "url",value = "新url内容"
            ,dataType = "String",paramType = "query",required = true)
    @PostMapping("/video")
    public ResponseStatus modifyVideoUrl(@RequestParam("url") String url) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.setCompanyIntroductionVideoUrl(url));
    }

    /**
     * 修改“企业简介”页面文本内容
     *
     * @param introduction
     * @return
     */
    @ApiOperation("文本内容的修改")
    @ApiImplicitParam(name = "introduction",value = "新文本内容"
            ,dataType = "String",paramType = "query",required = true)
    @PostMapping("/text")
    public ResponseStatus modifyText(@RequestParam("introduction") String introduction) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.setCompanyIntroductionText(introduction));
    }


    /**
     * 修改“企业简介”页面标题内容
     *
     * @param title
     * @return
     */
    @ApiOperation("标题的修改")
    @ApiImplicitParam(name = "title",value = "新标题内容"
            ,dataType = "String",paramType = "query",required = true)
    @PostMapping("/title")
    public ResponseStatus modifyTitle(@RequestParam("title") String title) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                companyIntroductionService.setCompanyIntroductionTitle(title));
    }

    /**
     //     * 通过图片id修改“企业简介”页面特定背景图
     //     *
     //     * @param id 图片id
     //     * @return
     //     */
//    @PutMapping("/image/{id}")
//    @ApiOperation("页面图片修改")
//    @ApiImplicitParams({ @ApiImplicitParam(name = "id",value = "原图片id"
//            ,dataType = "Long",paramType = "path",required = true),
//                       @ApiImplicitParam(name = "file",value = "新上传图片信息"
//            ,dataType = "file",paramType = "form",required = true)})
//    public ResponseStatus modifyImage(@RequestPart("file") MultipartFile file, @PathVariable("id") Long id) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                companyIntroductionService.modifCompanyIntroducitonImage(file,id));
//    }


//    /**
//     * 添加“企业简介”页面标题内容
//     */
//    @ApiOperation("企业简介 页面文本内容的添加接口")
//    @ApiImplicitParam(name = "introduction",value = "文本内容"
//            ,dataType = "String",paramType = "query",required = true)
//    @PostMapping("/text")
//    public ResponseStatus addTitle(@RequestParam("introduction") String introduction) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                companyIntroductionService.setCompanyIntroductionText(introduction));
//    }
//
//    /**
//     * 添加“企业简介”页面文本内容
//     */
//    @ApiOperation("企业简介 页面标题的添加接口")
//    @ApiImplicitParam(name = "title",value = "标题内容"
//            ,dataType = "String",paramType = "query",required = true)
//    @PostMapping("/title")
//    public ResponseStatus addText(@RequestParam("title") String title) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                companyIntroductionService.setCompanyIntroductionTitle(title));
//    }

}
